package com.example.fw;

import java.util.Properties;

import org.netbeans.jemmy.ClassReference;
import org.netbeans.jemmy.operators.JFrameOperator;

public class ApplicationManager {

	private StringBuffer verificationErrors = new StringBuffer();
	private Properties properties;
	private FolderHelper folderHelper;
	private MenuHelper menuHelper;
	private JFrameOperator mainFrame;
	private TreeHelper treeHelper;
	private DialogHelper dialogHelper;
	
	public ApplicationManager(Properties properties){
	    this.properties = properties;
	}

	public void stop() {	
		getApplication().requestClose();
	}

	public FolderHelper getFolderHelper() {
		if (folderHelper == null){
			folderHelper = new FolderHelper(this);
		}
		return folderHelper;
	}
	
	public MenuHelper getMenuHelper() {
		if (menuHelper == null){
			menuHelper = new MenuHelper(this);
		}
		return menuHelper;
	}
	
	public TreeHelper getTreeHelper() {
		if (treeHelper == null){
			treeHelper = new TreeHelper(this);
		}
		return treeHelper;
	}
	
	public DialogHelper getDialogHelper() {
		if (dialogHelper == null){
			dialogHelper = new DialogHelper(this);
		}
		return dialogHelper;
	}

	public JFrameOperator getApplication() {
		if (mainFrame == null){
		try {
			new ClassReference("addressbook.AddressBookFrame").startApplication();
			mainFrame = new JFrameOperator("jAddressBook");
		} catch (Exception e) {
			e.printStackTrace();
		}
		}
		return mainFrame;
	}


	
}
